﻿
using BCGM.MedicalWisdom.IServices;
using BCGM.MedicalWisdom.Model.Models;
using BCGM.MedicalWisdom.Services.BASE;
using BCGM.MedicalWisdom.Repository.BASE;
using System.Threading.Tasks;
using System.Collections.Generic;
using BCGM.MedicalWisdom.Model.ViewModels.Order;
using SqlSugar;

namespace BCGM.MedicalWisdom.Services
{
    public class AddressServices : BaseServices<Address>, IAddressServices
    {
        private readonly IBaseRepository<Address> _dal;
        public AddressServices(IBaseRepository<Address> dal)
        {
            this._dal = dal;
            base.BaseDal = dal;
        }

        public async Task<List<AddressOutputDto>> GetAddressOutputsSql()
        {
            string sql = "select * from Address where IsDeleted = 0;";
            SugarParameter[] parameters = null;
            var list = await base.BaseDal.QuerySql(sql, parameters);
            List<AddressOutputDto> addressOutputDtos = new List<AddressOutputDto>();
            foreach (var item in list)
            {
                addressOutputDtos.Add(new AddressOutputDto()
                {
                    AddressId = item.AddressId,
                    AddrName = item.AddrName,
                    AreaId = item.AreaId,
                    Createdby = item.Createdby,
                    CreateTime = item.CreateTime,
                    Updatedby = item.Updatedby,
                    UpdatedTime = item.UpdatedTime,
                    Deletedby = item.Deletedby,
                    DeletedTime = item.DeletedTime,
                    IsDeleted = item.IsDeleted,
                });
            }
            return addressOutputDtos;
        }
    }
}